#ifndef GPSINTERFACE_H
#define GPSINTERFACE_H

#include <QObject>
#include <QThread>
#include <QTime>

#include "gps.h"

class gpsdProc : public QThread
{
    Q_OBJECT
    public:
        gpsdProc();
        virtual ~gpsdProc();
        double longitude;
        double latitude;
        double time;

    signals:
        void changeData();

    protected:
        virtual void run();

        gps_data_t* gpsdata;

        bool decodeData();
        int pipe_fd;

};

class gpsinterface : public QObject
{
    Q_OBJECT
public:
    explicit gpsinterface(QObject *parent = 0);
    QTime m_Sunrise;
    QTime m_Sunset;
    QDateTime currDateTime;
    bool nowNight();
    bool nowDay();

signals:
    void riseset();

private slots:
    void calculate();

private:
    bool day, night;
    double m_fLong; //долгота
    double m_fLat; //широта
    gpsdProc *gpsDataloger;

    double DegreesToRadians(double x);
    double RadiansToDegrees(double x);
    void ComputeSunriset();
};

#endif // GPSINTERFACE_H
